<?php $this->load->view('layout/header');?>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <h3 class="page-title">旅游商品<small>商品供应商商品类别</small></h3>
            <?php echo breadcrumb(array('tourismprovidercategory/grid'=>'旅游商品','tourismprovidercategory/add'=>'添加商品供应商商品类别')); ?>
        </div>
    </div>
    <?php echo execute_alert_message()?>
    <div class="row-fluid">
        <div class="span12">
            <div class="portlet box green">
                <div class="portlet-title">
                    <div class="caption"><i class="icon-plus-sign"></i>添加商品供应商商品类别</div>
                    <div class="tools">
                        <a class="collapse" href="javascript:;"></a>
                        <a class="remove" href="javascript:;"></a>
                    </div>
                </div>
                <div class="portlet-body form">
                    <form class="form-horizontal provider-form" action="<?php echo base_url('tourismprovidercategory/addPost') ?>" method="post">
                        <div class="control-group add-supplieruid-html">
                            <label class="control-label"><em>* </em>供应商uid</label>
                            <div class="controls">
                                <input type="text" name="provider_uid" class="m-wrap large supplieruid required tooltips number" data-original-title="双击可弹框选择供应商；直接输入‘用户名称或编号’可提示" data-trigger="hover"  value="<?php echo $this->input->get('uid');?>">
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label"><em>* </em>类别名称</label>
                            <div class="controls">
                                <input type="text" name="category_name" class="m-wrap large required">
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label"><em>* </em>是否主推</label>
                            <div class="controls">
                                <select name="is_main" class="m-wrap large">
                                    <option value="1" selected="selected">否</option>
                                    <option value="2">是</option>
                                </select>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">上下架</label>
                            <div class="controls">
                                <select name="is_on_sale" class="m-wrap large">
                                    <option value="1">上架</option>
                                    <option value="2" selected="selected">下架</option>
                                </select>
                            </div>
                        </div>
                        <div class="control-group add-supplieruid-html">
                            <label class="control-label">排序</label>
                            <div class="controls">
                                <input type="text" name="sort" value="1" class="m-wrap large" placeholder="越大越前">
                            </div>
                        </div>

                        <div class="form-actions">
                            <button class="btn green" type="submit"><i class="icon-ok"></i> 保存</button>
                            <a href="<?php echo base_url('tourismprovidercategory/grid') ?>">
                                <button class="btn" type="button">返回</button>
                            </a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $('form.provider-form').validate({
        rules:{
            category_name : {
                remote:{
                    url  : hostUrl()+'/tourismprovidercategory/checkUidCategoryName',
                    type : 'post',
                    dataType : 'json',
                    data : {
                        'provider_uid' : function(){return $('input[name="provider_uid"]').val();},
                        'category_name' : function(){return $('input[name="category_name"]').val();},
                    }
                }
            }
        },
        messages:{
            category_name : { remote:'类别名称重复'}
        }
    });
    /*主推只有一个*/
    $('select[name="is_main"]').on('change','', function () {
        var is_main_value = $('select[name="is_main"] option:selected').val();
        if ( is_main_value == 2 ) {
            alert('主推类别一个供应商只能设置一个，是否确认');
        }
    }
  );


</script>
<?php $this->load->view('layout/footer');?>
<?php $this->load->view('user/addSupplierUid/ajaxGetUser');?>
